home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8531 < prev    next >
Encoding:
Text File  |  1996-08-05  |  913 b   |  36 lines

  1. Path: news.ner.bbnplanet.net!forest!ebromber
  2. From: ebromber@forest.drew.edu
  3. Newsgroups: comp.lang.c
  4. Subject: Why doesn't this work?
  5. Message-ID: <1996Mar4.161412.137442@forest>
  6. Date: 4 Mar 96 16:14:12 EST
  7. Organization: Drew University
  8.  
  9. Does anyone know why this password program doesn't work properly? And if 
  10. you do know the problem how can I fix it? It rejects every password including 
  11. the real password. The program was compiled using a MS-DOS compiler.
  12. Thanks in advance.
  13. ebromber@drew.edu
  14.  
  15. main();
  16. {    char real[4];
  17.     char pass[100];
  18.     int count=0;
  19.     int i, error;
  20.     char c;
  21.     real[0]='j';real[1]='e';real[2]='r';real[3]='k';
  22.     printf("PASSWORD: ");
  23.     fflush(stdout);
  24.     while (c=getch() !='\n')
  25.     {     count++;
  26.         pass[count]=c;
  27.         putch('*');
  28.     }
  29.     if (count!=4) { printf("\nWRONG PASSWORD\n"); main();}
  30.     error=0;
  31.     for (i=0; i<4; i++)
  32.         if (real[i]=pass[i]) error++;
  33.     if (error>0) {printf("\nWRONG PASSWORD\n"); main();}
  34. }
  35.  
  36.